# eric7.VirtualEnv.VirtualenvManager

Module implementing a class to manage Python virtual environments.

### Global Attributes

None

### Classes

VirtualenvManager | Class implementing an object to manage Python virtual environments.

### Functions

None

## VirtualenvManager

Class implementing an object to manage Python virtual environments.

### Signals

virtualEnvironmentAdded()
  emitted to indicate the addition of a virtual environment
virtualEnvironmentChanged(name)
  emitted to indicate a change of a virtual environment
virtualEnvironmentRemoved()
  emitted to indicate the removal and deletion of a virtual environment
virtualEnvironmentTypeRegistered()
  emitted to indicate that a new virtual environment type has been registered
virtualEnvironmentTypeUnregistered()
  emitted to indicate that a virtual environment type has been unregistered
virtualEnvironmentsListChanged()
  emitted to indicate a change of the list of virtual environments (may be used to refresh the list)

### Derived from

QObject

### Class Attributes

DefaultKey
SystemKey

### Class Methods

None

### Methods

VirtualenvManager | Constructor
__checkEnvironmentInterpretersExist | Private method to set all environments with non-existent interpreters to the disabled state.
__cleanEnvironments | Private method to delete all non-existent local or eric-ide server environments.
__createStandardVirtualEnv | Private method to create a standard (pyvenv or virtualenv) environment.
__deleteStandardVirtualEnv | Private method to delete a given virtual environment from disk.
__isEnvironmentDeleteable | Private method to check, if a virtual environment can be deleted from disk.
__loadSettings | Private slot to load the virtual environments.
__saveSettings | Private slot to save the virtual environments.
__upgradeStandardVirtualEnv | Private method to delete a given virtual environment from disk.
addVirtualEnv | Public method to add a virtual environment.
createVirtualEnv | Public slot to create a new virtual environment.
deleteVirtualEnvs | Public method to delete virtual environments from the list and disk.
environmentForInterpreter | Public method to get the environment a given interpreter belongs to.
getDefaultEnvironment | Public method to get the default virtual environment.
getEnvironmentEntries | Public method to get a list of the defined virtual environment entries.
getEnvironmentTypeEntry | Public method to get the environment type entry of the given type.
getEnvironmentTypeNames | Public method to get a list of names of registered virtual environment types.
getEnvironmentTypesRegistry | Public method to get a reference to the virtual environment types registry object.
getEricServerEnvironmentNames | Public method to get a list of defined eric-ide server environments.
getVirtualEnvironmentsBaseDir | Public method to set the base directory for the virtual environments.
getVirtualenvDirectory | Public method to get the directory of a virtual environment.
getVirtualenvExecPath | Public method to get the search path prefix of a virtual environment.
getVirtualenvInterpreter | Public method to get the interpreter for a virtual environment.
getVirtualenvNames | Public method to get a list of defined virtual environments.
isAvailableEnvironment | Public method to test, if a given environment is available.
isEricServerEnvironment | Public method to test, if a given environment is an environment accessed through an eric-ide server.
isGlobalEnvironment | Public method to test, if a given environment is a global one.
isUnique | Public method to check, if the give logical name is unique.
registerType | Public method to register a new virtual environment type.
reloadSettings | Public slot to reload the virtual environments.
removeVirtualEnvs | Public method to delete virtual environments from the list.
renameVirtualEnv | Public method to substitute a virtual environment entry with a new name.
searchUnregisteredInterpreters | Public method to search for unregistered Python interpreters.
setVirtualEnv | Public method to change a virtual environment.
setVirtualEnvInterpreter | Public method to change the interpreter for a virtual environment.
setVirtualEnvironmentsBaseDir | Public method to set the base directory for the virtual environments.
showVirtualenvManagerDialog | Public slot to show the virtual environment manager dialog.
unregisterType | Public method to unregister the virtual environment type of the given name.
upgradeVirtualEnv | Public slot to upgrade a virtual environment.

### Static Methods

None

#### VirtualenvManager (Constructor)

VirtualenvManager(parent=None)

Constructor

parent (QWidget)
  reference to the parent object

#### VirtualenvManager.__checkEnvironmentInterpretersExist

__checkEnvironmentInterpretersExist()

Private method to set all environments with non-existent interpreters to the disabled state.

#### VirtualenvManager.__cleanEnvironments

__cleanEnvironments()

Private method to delete all non-existent local or eric-ide server environments.

#### VirtualenvManager.__createStandardVirtualEnv

__createStandardVirtualEnv(baseDir="")

Private method to create a standard (pyvenv or virtualenv) environment.

baseDir (str (optional))
  base directory for the virtual environments (defaults to "")

#### VirtualenvManager.__deleteStandardVirtualEnv

__deleteStandardVirtualEnv(venvMetaData)

Private method to delete a given virtual environment from disk.

venvMetaData (VirtualenvMetaData)
  virtual environment meta data structure

Return:
  flag indicating success

Return Type:
  bool

#### VirtualenvManager.__isEnvironmentDeleteable

__isEnvironmentDeleteable(venvName)

Private method to check, if a virtual environment can be deleted from disk.

venvName (str)
  name of the virtual environment

Return:
  flag indicating it can be deleted

Return Type:
  bool

#### VirtualenvManager.__loadSettings

__loadSettings()

Private slot to load the virtual environments.

#### VirtualenvManager.__saveSettings

__saveSettings()

Private slot to save the virtual environments.

#### VirtualenvManager.__upgradeStandardVirtualEnv

__upgradeStandardVirtualEnv(venvMetaData)

Private method to delete a given virtual environment from disk.

venvMetaData (VirtualenvMetaData)
  virtual environment meta data structure

#### VirtualenvManager.addVirtualEnv

addVirtualEnv(metadata)

Public method to add a virtual environment.

metadata (VirtualenvMetaData)
  object containing the metadata of the virtual environment

#### VirtualenvManager.createVirtualEnv

createVirtualEnv(baseDir="")

Public slot to create a new virtual environment.

baseDir (str (optional))
  base directory for the virtual environments (defaults to "")

#### VirtualenvManager.deleteVirtualEnvs

deleteVirtualEnvs(venvNames)

Public method to delete virtual environments from the list and disk.

venvNames (list of str)
  list of logical names for the virtual environments

#### VirtualenvManager.environmentForInterpreter

environmentForInterpreter(interpreter)

Public method to get the environment a given interpreter belongs to.

interpreter (str)
  path of the interpreter

Return:
  tuple containing the environment name and a copy of the metadata of the virtual environment the interpreter belongs to

Return Type:
  tuple of (str, VirtualenvMetaData)

#### VirtualenvManager.getDefaultEnvironment

getDefaultEnvironment()

Public method to get the default virtual environment.

Default is an environment with the key '' or the first one having an interpreter matching sys.executable (i.e. the one used to execute eric with)

Return:
  tuple containing the environment name and a copy of the metadata of the default virtual environment

Return Type:
  tuple of (str, VirtualenvMetaData)

#### VirtualenvManager.getEnvironmentEntries

getEnvironmentEntries()

Public method to get a list of the defined virtual environment entries.

Return:
  list containing a copy of the defined virtual environments

Return Type:
  list

#### VirtualenvManager.getEnvironmentTypeEntry

getEnvironmentTypeEntry(environmentType)

Public method to get the environment type entry of the given type.

environmentType (str)
  environment type to retrieve the entry for

Return:
  environment type entry

Return Type:
  VirtualenvType

#### VirtualenvManager.getEnvironmentTypeNames

getEnvironmentTypeNames()

Public method to get a list of names of registered virtual environment types.

Return:
  list of tuples of virtual environment type names and their visual name

Return Type:
  list of tuple of (str, str)

#### VirtualenvManager.getEnvironmentTypesRegistry

getEnvironmentTypesRegistry()

Public method to get a reference to the virtual environment types registry object.

Return:
  reference to the virtual environment types registry object

Return Type:
  VirtualenvTypeRegistry

#### VirtualenvManager.getEricServerEnvironmentNames

getEricServerEnvironmentNames(host="")

Public method to get a list of defined eric-ide server environments.

host (str (optional))
  host name to get environment names for (defaults to "")

Return:
  list of defined eric-ide server environments

Return Type:
  list of str

#### VirtualenvManager.getVirtualEnvironmentsBaseDir

getVirtualEnvironmentsBaseDir()

Public method to set the base directory for the virtual environments.

Return:
  base directory for the virtual environments

Return Type:
  str

#### VirtualenvManager.getVirtualenvDirectory

getVirtualenvDirectory(venvName)

Public method to get the directory of a virtual environment.

venvName (str)
  logical name for the virtual environment

Return:
  directory path

Return Type:
  str

#### VirtualenvManager.getVirtualenvExecPath

getVirtualenvExecPath(venvName)

Public method to get the search path prefix of a virtual environment.

venvName (str)
  logical name for the virtual environment

Return:
  search path prefix

Return Type:
  str

#### VirtualenvManager.getVirtualenvInterpreter

getVirtualenvInterpreter(venvName)

Public method to get the interpreter for a virtual environment.

venvName (str)
  logical name for the virtual environment

Return:
  interpreter path

Return Type:
  str

#### VirtualenvManager.getVirtualenvNames

getVirtualenvNames(noGlobals=False, filterList=("all", ))

Public method to get a list of defined virtual environments.

noGlobals (bool (optional))
  flag indicating to exclude global environments (defaults to False)
filterList (tuple of str ((optional))
  tuple containing the list of virtual environment types to be included (prefixed by +) or excluded (prefixed by -) (defaults to ("all",) )

Return:
  list of defined virtual environments

Return Type:
  list of str

#### VirtualenvManager.isAvailableEnvironment

isAvailableEnvironment(venvName)

Public method to test, if a given environment is available.

venvName (str)
  logical name of the virtual environment

Return:
  flag indicating an available environment

Return Type:
  bool

#### VirtualenvManager.isEricServerEnvironment

isEricServerEnvironment(venvName, host="")

Public method to test, if a given environment is an environment accessed through an eric-ide server.

venvName (str)
  logical name of the virtual environment
host (str (optional))
  name of the host to check for or empty string to just check for an eric-ide server environment (defaults to "")

Return:
  flag indicating an eric-ide server environment

Return Type:
  bool

#### VirtualenvManager.isGlobalEnvironment

isGlobalEnvironment(venvName)

Public method to test, if a given environment is a global one.

venvName (str)
  logical name of the virtual environment

Return:
  flag indicating a global environment

Return Type:
  bool

#### VirtualenvManager.isUnique

isUnique(venvName)

Public method to check, if the give logical name is unique.

venvName (str)
  logical name for the virtual environment

Return:
  flag indicating uniqueness

Return Type:
  bool

#### VirtualenvManager.registerType

registerType(venvType)

Public method to register a new virtual environment type.

venvType (VirtualenvType)
  virtual environment data

#### VirtualenvManager.reloadSettings

reloadSettings()

Public slot to reload the virtual environments.

#### VirtualenvManager.removeVirtualEnvs

removeVirtualEnvs(venvNames)

Public method to delete virtual environments from the list.

venvNames (list of str)
  list of logical names for the virtual environments

#### VirtualenvManager.renameVirtualEnv

renameVirtualEnv(oldVenvName, metadata, )

Public method to substitute a virtual environment entry with a new name.

oldVenvName (str)
  old name of the virtual environment
metadata (VirtualenvMetaData)
  object containing the metadata of the virtual environment

#### VirtualenvManager.searchUnregisteredInterpreters

searchUnregisteredInterpreters()

Public method to search for unregistered Python interpreters.

Return:
  list of unregistered interpreters

Return Type:
  list of str

#### VirtualenvManager.setVirtualEnv

setVirtualEnv(metadata)

Public method to change a virtual environment.

metadata (VirtualenvMetaData)
  object containing the metadata of the virtual environment

#### VirtualenvManager.setVirtualEnvInterpreter

setVirtualEnvInterpreter(venvName, venvInterpreter)

Public method to change the interpreter for a virtual environment.

venvName (str)
  logical name for the virtual environment
venvInterpreter (str)
  interpreter path to be set

#### VirtualenvManager.setVirtualEnvironmentsBaseDir

setVirtualEnvironmentsBaseDir(baseDir)

Public method to set the base directory for the virtual environments.

baseDir (str)
  base directory for the virtual environments

#### VirtualenvManager.showVirtualenvManagerDialog

showVirtualenvManagerDialog(modal=False)

Public slot to show the virtual environment manager dialog.

modal (bool)
  flag indicating that the dialog should be shown in a blocking mode

#### VirtualenvManager.unregisterType

unregisterType(name)

Public method to unregister the virtual environment type of the given name.

name (str)
  name of the virtual environment type

#### VirtualenvManager.upgradeVirtualEnv

upgradeVirtualEnv(venvName)

Public slot to upgrade a virtual environment.

venvName (str)
  name of the virtual environment

Up